const fse = require('fs-extra');
const path = require('path');
const Boom = require('boom');
/**
 * 挂载路由
 */
const routerOption = {
    throw: true,
    notImplemented: () => new Boom.notImplemented(),
    methodNotAllowed: () => new Boom.methodNotAllowed()
};
module.exports = app => {
    const routerPath = path.resolve(__dirname, '../routes');
    const routerList = fse.readdirSync(routerPath);
    routerList.forEach(item => {
        const router = require(path.resolve(routerPath, item));
        app.use(router.routes()).use(router.allowedMethods(routerOption));
    });
};
